package com.example.demo;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;

@SpringBootApplication
@RestController
@Slf4j
public class DemoApplication {

    @Autowired
    private ServerConfig serverConfig;

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }


    @RequestMapping("test")
    public String test() {
        InetAddress address = null;
        try {
            address = InetAddress.getLocalHost();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        log.info("这是我的nginx 测试日志，当前端口为:{}",serverConfig.getUrl());
//        try {
//            int m = 0;
//            int i = 3 / m;
//        } catch (Exception e) {
//            log.error("fwefwfw，异常信息为:{}", ExceptionUtils.getStackTrace(e));
//        }


        return "OK";
    }

    @RequestMapping("master1")
    public String master() {
        int i = 1;
        List<User> users = new ArrayList<>();
//        while (i==1){
//            User user=new User();
//            user.setAddress("飞机滴哦瑟夫Joe的司法局而覅洁柔飞机饿哦日附件二org金佛欸");
//            user.setName("erhjfigoufiufiufiufiufiufiufiufiufiufiufiufiufiufiufiufiufiufiufiufiufiufiufiufiufiufiufiufiufiufiufiufiufiufi");
//            users.add(user);
//        }
        return "Master1";
    }
}
